/**
 * Created by wushuai on 16-12-21.
 */
$(document).ready(function(){
    $(".block li:first").addClass("positive");
    $(".card-title div:first").addClass("point");
    $(".card-list ul:first").hide();
    $(".card-content:first").show();
    $(".item-desc").hide();
    $(".look").hide();
    get_hide_show();
    get_title_show();
    get_mouse_event()
});

function get_hide_show(){
    $(".card-item").mouseenter(function (){
        $(".card-list ul:first").show();
        if($(".card-content",this).is(':hidden') == true){
            $(".card-content").hide();
            $(".card-list").show();
            $(".content").css("color","#373D41");
            $(".gray").css("background-color","#EBEBEC");
            $(".glod").css("background-color","#E5E5E6");
            $(".card-item").css({"width":"275px","height":"550px","border":"1px #DBDBDD","border-style":"solid none solid solid"});
            $(this).css({"width":"360px","height":"580px","border":"1px solid #00c1de"});
            $(".gray",this).css("background-color","#00c1de");
            $(".glod",this).css("background-color","#00c1de");
            $(".content",this).css("color","white");
            $(".card-content",this).show();
            $(".card-list",this).hide();
        }
        else{
            $(".card-content",this).show();
            $(".card-list",this).hide();
        }
    });
}
function get_title_show(){
    $(".program-item").mouseenter(function(){
        $(".item-desc",this).css("display","inline-block");
        $(".item-desc",this).show();
        $(".look",this).css("display","inline-block");
        $(".look",this).show();
        $(".item-line",this).stop();
        $(".item-line",this).animate({opacity:0,top: "-90"},{duration:1000});
        $(".item-title",this).stop();
        $(".item-desc",this).stop();
        $(".look",this).stop();
        $(".item-title",this).animate({top: "-90"},{duration:1000});
        $(".item-desc",this).animate({opacity: 1, top: "-90"}, {duration: 1000});
        $(".look",this).animate({opacity: 1, top: "-90"}, {duration: 1000});
    }).mouseleave(function(){
        $(".item-title",this).stop();
        $(".item-desc",this).stop();
        $(".look",this).stop();
        $(".item-line",this).stop();
        $(".item-line",this).animate({opacity:1,top: "0"},{duration:1000});
        $(".item-title",this).animate({top: "5"},{duration:1000});
        $(".item-desc",this).animate({opacity:0, top: "5"},{duration:1000});
        $(".look",this).animate({opacity: 0,top: "5"},{duration:1000});
    });
}
function get_mouse_event(){
    $(".slide").mouseenter(function(){
        $(".icon-arrow-left").show();
        $(".move").show();
    }).mouseleave(function(){
        $(".icon-arrow-left").hide();
        $(".move").hide();
    })
}
var next = document.getElementById('left');
var prev = document.getElementById('right');
var curindex=0;
next.onclick = function(){
    var event;
    clearInterval(event);
    event = setInterval(function(){
        clearInterval(event);
        var lists = $('.photo-items');
        curindex -=5;
        var left = parseInt(lists.css('left'));
         if(left<-1288){
            lists.css('left',-257.6);
        }else if(left>-257.6){
            lists.css('left',-1288);
        }
        $("#cycle").animate({left: +0 + "px"}, 2000, function(){
            var temp = $("#cycle li:nth-child(n+6)").clone(true);
            $("#cycle li:nth-child(n+6)").remove();
            $("#cycle").css('left',"0");
            $("#cycle").prepend(temp);
        });
    },17);
}
prev.onclick = function(){
    var event;
    clearInterval(event);
    event = setInterval(function (){
        clearInterval(event);
        curindex += 5;
        $("#cycle").animate({left: -1288 + "px"}, 2000, function () {
            var temp = $("#cycle li:nth-child(-n+5)").clone(true);
            $("#cycle li:nth-child(-n+5)").remove();
            $("#cycle").css('left',"0");
            $("#cycle").append(temp);
        });
    },17);
}










